package com.pattern.once.singleton;


/***
 * 双重判定锁实现方式
 */

public class SingletonDemo {


    private String name;

    private  static SingletonDemo singletonDemo;

    private SingletonDemo() {
    }

    public static SingletonDemo getSingletonDemo() {

        if (singletonDemo==null){
            synchronized (SingletonDemo.class){
                if (singletonDemo==null){
                    singletonDemo = new SingletonDemo();
                }
            }
        }

        return singletonDemo;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
